SearchField =  Ext.extend(Ext.form.TriggerField, {
	triggerClass:'x-form-search-trigger',
	initComponent:function() {
		SearchField.superclass.initComponent.apply(this, arguments);
		
	}
	,initEvents:function() {
		SearchField.superclass.initEvents.apply(this, arguments);
		this.on({
			onfind:this.OnFindSearch,
			setPassValue:this.setPassValue
		});
	},
	OnFindSearch:function(f) {
		
	},
	setPassValue:function(rec) {
		if(rec) {
			if(rec.data){
				if(rec.data['deptId']) {
					this.passField.value = rec.data['deptId'];
					this.setValue(rec.data['deptName']);
				}
				
			}
		}
//		this.passField.value = v1;
//		this.setValue(v2);
	},
	listeners : {
		'render' : {
		fn : function() {
				if (this.passName) {
                    this.passField = this.getEl().insertSibling({
                        tag : 'input',
                        type : 'hidden',
                        name : this.passName,
                        id : this.passId || Ext.id()
                    }, 'before', true)
                }
				this.passField.value = this.passValue !== undefined
                        ? this.passValue
                        : (this.value !== undefined ? this.value : '');
                //this.el.dom.removeAttribute('name');
                var se = this.el.dom.parentNode.getElementsByTagName("img")[0];
                var f = this ;
                se.onclick = function() {
                	f.fireEvent('onfind', f);
                }
                
		}
		}
	}

});

Ext.reg('searchfield', SearchField); 

